package com.orm.mediator;

import com.alibaba.fastjson.JSON;
import com.decorator.LoginSsoDecorator;
import com.orm.po.User;
import com.sun.org.slf4j.internal.Logger;
import org.junit.Test;
import org.slf4j.LoggerFactory;


import java.io.Reader;

public class test {

    private Logger logger = (Logger) LoggerFactory.getLogger(LoginSsoDecorator.class);

    @Test
    public void test_queryUserInfoById() {
        String resource = "mybatis-config-datasource.xml";
        Reader reader;
        try {
            reader = Resources.getResourceAsReader(resource);
            SqlSessionFactory sqlMapper = new
                    SqlSessionFactoryBuilder().build(reader);
            SqlSession session = sqlMapper.openSession();
            try {
                User user =
                        session.selectOne("org.itstack.demo.design.dao.IUserDao.queryUserInfoById"
                                , 1L);
                logger.warn( JSON.toJSONString(user));
            } finally {
                session.close();
                reader.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
